def remove_rust_comments(code: str) -> str:
    """
    删除Rust代码中的所有注释，正确处理嵌套的块注释

    参数:
        code: 包含注释的Rust代码字符串

    返回:
        删除注释后的代码字符串
    """
    result = []
    block_comment_level = 0  # 跟踪块注释的嵌套层级
    in_string = False
    i = 0

    while i < len(code):
        if block_comment_level > 0:
            # 在块注释内部
            if code[i:i+2] == '/*':
                block_comment_level += 1
                i += 2
                continue
            elif code[i:i+2] == '*/':
                block_comment_level -= 1
                i += 2
                continue
            i += 1
            continue

        if in_string:
            # 处理字符串中的转义字符
            if code[i] == '\\':
                result.append(code[i:i+2])
                i += 2
                continue
            # 检查字符串是否结束
            if code[i] == '"':
                in_string = False
            result.append(code[i])
            i += 1
            continue

        # 检查是否进入字符串
        if code[i] == '"':
            in_string = True
            result.append(code[i])
            i += 1
            continue

        # 检查是否遇到行注释
        if code[i:i+2] == '//':
            # 跳过直到行尾或文件尾
            while i < len(code) and code[i] != '\n':
                i += 1
            continue

        # 检查是否遇到块注释
        if code[i:i+2] == '/*':
            block_comment_level += 1
            i += 2
            continue

        result.append(code[i])
        i += 1

    return ''.join(result)
